package cn.dankal.flyaudio.home

import android.os.Bundle
import android.view.View
import cn.dankal.basiclib.base.BaseRvFragmentImp
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewAdapter
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewPresenter
import cn.dankal.basiclib.base.recyclerview.OnRvItemClickListener
import cn.dankal.basiclib.protocol.MainProtocol
import cn.dankal.business.pojo.ActivityBean
import cn.dankal.business.Constants
import cn.dankal.business.Constants.TYPE
import com.alibaba.android.arouter.launcher.ARouter

class MyActivityFragment : BaseRvFragmentImp<ActivityBean>() {

    companion object {

        fun newInstance(type: Int): MyActivityFragment {
            val fragment = MyActivityFragment()
            var bundle = Bundle()
            bundle.putInt(TYPE, type)
            fragment.arguments = bundle
            return fragment
        }
    }


    override fun getPresenter(): BaseRecyclerViewPresenter<ActivityBean>? {
        return MyActivityPrsenter(arguments?.getInt(TYPE))
    }

    override fun getAdapter(): BaseRecyclerViewAdapter<ActivityBean>? {
        var activityAdapter = ActivityAdapter()
        activityAdapter.setOnRvItemClickListener(object : OnRvItemClickListener<ActivityBean>() {
            override fun onItemClick(v: View?, position: Int, data: ActivityBean) {
                ARouter.getInstance().build(MainProtocol.ACTIVITY_DETAIL)
                        .withString(Constants.UUID, data.userApplyUuid)
                        .withString(Constants.INTO_TYPE, "2")
                        .navigation()
            }
        })
        return activityAdapter
    }
}
